(function() {
	$('#LogIn').click(function() {
		$('#error').text("");
		var _n = $("input[name='email']").val().trim();
		var _p = $("input[name='password']").val().trim();
		var emailReg = /^([a-zA-Z0-9_-])+@[a-zA-Z0-9_-]+[\.][a-zA-Z0-9_-]+/;
		var err = {
			state : false,
			msg : ""
		};
		if (!emailReg.test(_n)) {
			err.state = true;
			err.msg = "*邮箱格式错误";
		} else {
			if (_p.length < 6) {
				err.state = true;
				err.msg = "*密码不能少于6位";
			}
		}

		if (err.state) {
			$('#error').text(err.msg);
			err.state = false;
			err.msg = "";
			return fasle;
		}
		/* url 需要修改 */
		$.post("/loginAction", {
			email : _n,
			password : _p
		}, function(data, status) {
			if (data == "0") {
				$('#error').text("*用户名或密码错误");
			} else {
				location.href = data;
			}
		}).error(function() {
			$('#error').text("*网络错误，请重试");
		});

	});
})();